#ifndef __OLED_H
#define __OLED_H			  	 
//#include "sys.h"
#include "Arduino.h"
#include "stdlib.h"	  

#ifdef __cplusplus
extern "C" {
#endif

 
#define OLED_W 240
#define OLED_H 320
#define	u8 unsigned char
#define	u16 unsigned int
#define	u32 unsigned long

//OLEDģʽ����
//0:4�ߴ���ģʽ
//1:����8080ģʽ
#define OLED_MODE 0
#define SIZE 16
#define XLevelL		0x00
#define XLevelH		0x10
#define Max_Column	128
#define Max_Row		64
#define	Brightness	0xFF 
#define X_WIDTH 	128
#define Y_WIDTH 	64	    					

#define USE_ESP32_HSPI 1

#define SCLK_PIN  32
#define DIN_PIN   33
#define RES_PIN   25
#define DC_PIN    26
#define BLK_PIN   27

//#define CS    10    
//#define CD    8
//#define RST   9
//#define MOSI  0 //12
//#define MISO  2 //13
//#define SCK   3 //14

//-----------------OLED�˿ڶ���----------------  					   
#define OLED_SCLK_Clr() (digitalWrite(SCLK_PIN,LOW)) //GPIO_ResetBits(GPIOB,GPIO_Pin_13)//CLK
#define OLED_SCLK_Set() (digitalWrite(SCLK_PIN,HIGH)) //GPIO_SetBits(GPIOB,GPIO_Pin_13)

#define OLED_SDIN_Clr() (digitalWrite(DIN_PIN,LOW)) //GPIO_ResetBits(GPIOB,GPIO_Pin_15)//DIN
#define OLED_SDIN_Set() (digitalWrite(DIN_PIN,HIGH)) //GPIO_SetBits(GPIOB,GPIO_Pin_15)

#define OLED_RST_Clr() (digitalWrite(RES_PIN,LOW)) //GPIO_ResetBits(GPIOB,GPIO_Pin_11)//RES
#define OLED_RST_Set() (digitalWrite(RES_PIN,HIGH)) //GPIO_SetBits(GPIOB,GPIO_Pin_11)

#define OLED_DC_Clr() (digitalWrite(DC_PIN,LOW)) //GPIO_ResetBits(GPIOB,GPIO_Pin_10)//DC
#define OLED_DC_Set() (digitalWrite(DC_PIN,HIGH)) //GPIO_SetBits(GPIOB,GPIO_Pin_10)
 		     
#define OLED_BLK_Clr() (digitalWrite(BLK_PIN,LOW)) //GPIO_ResetBits(GPIOB,GPIO_Pin_12)//CS
#define OLED_BLK_Set() (digitalWrite(BLK_PIN,HIGH)) //GPIO_SetBits(GPIOB,GPIO_Pin_12)


//#define OLED_BLK_Clr()  GPIO_ResetBits(GPIOB,GPIO_Pin_10)//CS
//#define OLED_BLK_Set()  GPIO_SetBits(GPIOB,GPIO_Pin_10)
 		     
#define OLED_CMD  0	//д����
#define OLED_DATA 1	//д����

extern  u16 OLED_BACK_COLOR, OLED_POINT_COLOR;   //����ɫ������ɫ

void OLED_Init(void); 
void OLED_Clear(u16 Color);
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2);

void OLED_BEGIN();
void OLED_END();
void OLED_transfer(const uint8_t * data, uint32_t size);

void OLED_WR_DATA8(char da); //��������-8λ����
void OLED_WR_DATA(int da);
void OLED_WR_REG(char da);

void OLED_DrawPoint(u16 x,u16 y);//����
void OLED_DrawPoint_big(u16 x,u16 y);//��һ�����
u16  OLED_ReadPoint(u16 x,u16 y); //����
void Draw_Circle(u16 x0,u16 y0,u8 r);
void OLED_DrawLine(u16 x1, u16 y1, u16 x2, u16 y2);
void OLED_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2);		   
void OLED_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
void OLED_ShowChar(u16 x,u16 y,u8 num,u8 mode);//��ʾһ���ַ�
void OLED_ShowNum(u16 x,u16 y,u32 num,u8 len);//��ʾ����
void OLED_Show2Num(u16 x,u16 y,u16 num,u8 len);//��ʾ2������
void OLED_ShowString(u16 x,u16 y,const u8 *p);		 //��ʾһ���ַ���,16����
 
void showhanzi(unsigned int x,unsigned int y,unsigned char index);



//������ɫ
#define WHITE         	 0xFFFF
#define BLACK         	 0x0000	  
#define BLUE         	 0x001F  
#define BRED             0XF81F
#define GRED 			 0XFFE0
#define GBLUE			 0X07FF
#define RED           	 0xF800
#define MAGENTA       	 0xF81F
#define GREEN         	 0x07E0
#define CYAN          	 0x7FFF
#define YELLOW        	 0xFFE0
#define BROWN 			 0XBC40 //��ɫ
#define BRRED 			 0XFC07 //�غ�ɫ
#define GRAY  			 0X8430 //��ɫ
//GUI��ɫ

#define DARKBLUE      	 0X01CF	//����ɫ
#define LIGHTBLUE      	 0X7D7C	//ǳ��ɫ  
#define GRAYBLUE       	 0X5458 //����ɫ
//������ɫΪPANEL����ɫ 
 
#define LIGHTGREEN     	 0X841F //ǳ��ɫ
#define LGRAY 			 0XC618 //ǳ��ɫ(PANNEL),���屳��ɫ

#define LGRAYBLUE        0XA651 //ǳ����ɫ(�м����ɫ)
#define LBBLUE           0X2B12 //ǳ����ɫ(ѡ����Ŀ�ķ�ɫ)



#ifdef __cplusplus
}
#endif
					  		 
#endif  
	 
	 



